package com.yunxin.websitebox.exception;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@ResponseBody
@Slf4j
public class ExceptionHandlerController {

    public static void print(Exception ex) {
        log.error(ex.toString());
        ex.printStackTrace();
    }

    //IO流异常
    @ExceptionHandler(value = UnauthorizedException.class)
    public Exception ioException(UnauthorizedException e) {
        e.printStackTrace();
        return new Exception("未授权异常");
    }
}
